import numpy as np

import pynumpak


def test():
    def f(x):
        return x + 1

    print(pynumpak.integrate.gauss_legendre(f, (1, 3), 4))  # 用复合五点 gauss_legendre 公式求积分
    print(pynumpak.integrate.romberg(f, (1, 3), 4))  # 用 romberg 法求积分

    print(pynumpak.interpolate.Lagrange(np.arange(10), f(np.arange(10)))(4.1))  # 用 Lagrange 公式进行插值
    print(pynumpak.interpolate.Linear(np.linspace(0, 9, 100), f(np.linspace(0, 9, 100)))(4.1))  # 线性插值


if __name__ == "__main__":
    test()
